using System;

namespace ebc.patterns
{
    public class ExceptionHandler<T>
    {
        private readonly Action<Exception> exceptionHandler;

        public ExceptionHandler(Action<Exception> exceptionHandler)
        {
            this.exceptionHandler = exceptionHandler;
        }


        public void In_CatchExceptions(T message)
        {
            try
            {
                this.Out_MessageToProcess(message);
            }
            catch (Exception ex)
            {
                this.exceptionHandler(ex);
            }
        }


        public event Action<T> Out_MessageToProcess;
    }
}